﻿<?php
ignore_user_abort(TRUE);
require_once("./interface.php");
require_once("./utils.php");
require_once("./interface.php");
require_once("./TechnicFunc.php");
require_once("./SoldierFunc.php");
require_once("./HotelFunc.php");
require_once("./OfficeFunc.php");
require_once("./MarketFunc.php");
require_once("./UnionFunc.php");
require_once("./StoreFunc.php");
require_once("./TroopFunc.php");
require_once("./global.php");
require_once("./report.php");

//mysql_connect()函数
$con = mysql_connect("127.0.0.1","root","111111");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("sanguo1", $con);//链接数据库

/*
$heros=sql_fetch_into_arrays("select * from sys_city_hero where command_base!=0 order by level desc,command_base desc ");//将领表
/*echo "<table width='600' border='1' cellpadding='0' cellspacing='0' bordercolor='#666666'>
  <tr>
    <td width='60' height='20'><div align='center'><strong>排名</strong></div></td> 
    <td height='20'><div align='center'><strong>将领</strong></div></td>
    <td height='20'><div align='center'><strong>君主</strong></div></td>
	<td height='20'><div align='center'><strong>等级</strong></div></td>
    <td height='20'><div align='center'><strong>统帅</strong></div></td>
    <td height='20'><div align='center'><strong>内政</strong></div></td>
    <td height='20'><div align='center'><strong>勇武</strong></div></td>
    <td height='20'><div align='center'><strong>智谋</strong></div></td>
  </tr>";*/
/*
$i=0;
$k=1;
while($i<=1000)
  {
$heros_uid=$heros['uid'][$i];
$junzhu=sql_fetch_into_arrays("select * from sys_user where uid=$heros_uid ");//君主名称
$sum_command=$heros['command_base'][$i]+$heros['command_add_on'][$i]+$heros['level'][$i];//统帅
$sum_affairs=$heros['affairs_base'][$i]+$heros['affairs_add_on'][$i]+$heros['affairs_add'][$i];//内政
$sum_bravery=$heros['bravery_base'][$i]+$heros['bravery_add_on'][$i]+$heros['bravery_add'][$i];//勇武
$sum_wisdom=$heros['wisdom_base'][$i]+$heros['wisdom_add_on'][$i]+$heros['wisdom_add_on'][$i];//智谋
$hero_hid=$heros['hid'][$i];
$hero_name=$heros['name'][$i];
$hero_junzhu=$junzhu['name'][0];
$hero_level=$heros['level'][$i];
mysql_query("INSERT INTO rank_hero (rank,hid,name,user,level,affairs,bravery,wisdom) 
VALUES ('$k', '$hero_hid', '$hero_name','$hero_junzhu','$hero_level','$sum_affairs','$sum_bravery','$sum_wisdom')");

  /* echo "<tr>
    <td width='60' height='20'><div align='center'>".$k."</div></td><td height='20'><div align='center'>".$heros['name'][$i]."</div></td>
    <td height='20'><div align='center'>".$junzhu['name'][0]."&nbsp;"."<td height='20'><div align='center'>".$heros['level'][$i]."&nbsp;"."<td height='20'><div align='center'>".$sum_command."<td height='20'><div align='center'>".$sum_affairs."<td height='20'><div align='center'>".$sum_bravery."<td height='20'><div align='center'>".$sum_wisdom."</td>
    </tr>";*/
  /*
  $i=$i+1;
  $k=$k+1;
  }
  //echo "</table>";

*/
  $d=0;
$ranks=sql_fetch_into_arrays("select * from rank_user order by rank ");//君主名称
while($ranks['rank'][$d]!="")
  {

$rank_s_u=$ranks['rank'][$d];
$uid_s_u=$ranks['uid'][$d];
//mysql_query("update sys_user set rank='$rank_s_u' where uid=$uid_s_u ");
mysql_query("UPDATE sys_user SET rank = $rank_s_u WHERE uid= '$uid_s_u'");

echo $rank_s_u."----".$uid_s_u."<br>";
$d=$d+1;
  }
 mysql_close($con);
?>



